package com.imooc.bilibili.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * ProjectName imooc-bilibili
 *
 * @author xieyucan
 * <br>CreateDate 2022/10/24 10:53
 */
@Slf4j
@Configuration
public class RabbitConfig {
    @Bean
    public Exchange exchange2()
    {
        return new TopicExchange("exchange.my.dead");
    }
    @Bean
    public Queue queue2()
    {
        return new Queue("my.dead");
    }
    @Bean
    public Binding binding2()
    {
        return new Binding(
                "my.dead",
                Binding.DestinationType.QUEUE,
                "exchange.my.dead",
                "key.#",
                null
        );
    }
    @Bean
    public Exchange exchange1()
    {
        return new DirectExchange("exchange.my.message");
    }

    @Bean
    public Queue queue1()
    {
        Map<String, Object> map = new HashMap<>();
        map.put("x-message-ttl",15000);
        map.put("x-dead-letter-exchange","exchange.my.dead");
        return new Queue("my.queue",true,false,false,map);
    }
    @Bean
    public Binding binding1()
    {
       return new Binding(
                "my.queue",
                Binding.DestinationType.QUEUE,
                "exchange.my.message",
                "key.my",
                null
        );
    }


    @Bean
    public Exchange exchange3()
    {
        return new DirectExchange("exchange.my.danmu");
    }

    @Bean
    public Queue queue3()
    {
        return new Queue("my.danmu");
    }
    @Bean
    public Binding binding3()
    {
        return new Binding(
                "my.danmu",
                Binding.DestinationType.QUEUE,
                "exchange.my.danmu",
                "key.danmu",
                null
        );
    }


}
